SQLite in Android

Table of Contents

1. TODO SQLite

When we need to store massive and structural data, as well as complicated queries, sorting, filtering or transaction, we should probably use SQLite. SQLite is built-in feature in Android.

1.1. How to Use?

The core class is SQLiteOpenHelper which abstracts away creation, update and downgrade.

  • Creation. When DB is first accessed, Android detects if the DB file exists. If not, then onCreate() method is invoked to execute table creation and data initialization.
  • Upgrade. Upon app upgrade or DB version upgrade, Android invokes onUpgrade() to migrate data or modify table structure.
  • Downgrade. When DB version downgrades, Android invokes onDowngrade().

About Storage. The DB file is stored under /data/data/<package_name>/databases/.

1.1.1. DB Creation

1.1.2. DB Retrieval

1.1.3. Insert Data

1.1.4. Queries

1.1.5. Update Data

1.1.6. Delete Data

1.1.7. Transactions

Date: 2026-05-28 Thu 00:00